package GUI;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.LayoutManager;
import java.util.ArrayList;
import java.util.List;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class GUI_page02_ProcessReturn extends JPanel {

	JLabel titleLabel;
	JButton returnButton;
	
	JLabel nameLabel;
	List<String> storeOptions;
	JComboBox storeList;
	
	JLabel receiptIDLabel;
	JTextField receiptIDField;
	JLabel itemUPCLabel;
	JTextField itemUPCField;
	
	JLabel resultLabel;
	
	JLabel amountLabel;
	JTextField amountField;
	JButton returnItemButton;
	
	public GUI_page02_ProcessReturn() {
		storeOptions = new ArrayList<String>();
		storeOptions.add("None");
		
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.setBackground(Color.white);
		
		// title label
		titleLabel = new JLabel("Return Item", JLabel.CENTER);
		titleLabel.setVerticalTextPosition(JLabel.CENTER);
		
		titleLabel.setHorizontalTextPosition(JLabel.CENTER);
		titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
		titleLabel.setFont(new Font("Century Gothic", Font.BOLD, 20));
		titleLabel.setForeground(Color.gray);
		this.add(titleLabel);
        
		this.add(Box.createRigidArea(new Dimension(0,15)));

        // return button
		returnButton = GUI_AMSStoreMain.makeGrayWhiteButton("Cancel", Component.LEFT_ALIGNMENT);
		this.add(returnButton);
        
        this.add(Box.createRigidArea(new Dimension(0,10)));
        
        // store drop down
        nameLabel = GUI_AMSStoreMain.makeLeftAlignedGrayLabel("Store of Return", 11);
        this.add(nameLabel);
        // list of stores to choose from, by default on first one
        Object[] tableStrings = storeOptions.toArray();
        storeList = new JComboBox(tableStrings);
        storeList.setSelectedIndex(0);
        storeList.setAlignmentX(Component.LEFT_ALIGNMENT);
        storeList.setForeground(Color.gray);
        storeList.setBackground(Color.white);
        storeList.setFont(new Font("Century Gothic", Font.PLAIN, 13));
        storeList.setMaximumSize(new Dimension(200,20));
        storeList.setSize(new Dimension(200, 20)); 
        this.add(storeList);
		
        this.add(Box.createRigidArea(new Dimension(0,5)));
        
        // receipt ID Field
        receiptIDLabel = GUI_AMSStoreMain.makeLeftAlignedGrayLabel("Receipt ID", 11);
        this.add(receiptIDLabel);
		receiptIDField = GUI_AMSStoreMain.makeLeftGrayTextField("", 200);
		this.add(receiptIDField);
		
		this.add(Box.createRigidArea(new Dimension(0,5)));
		
		// item UPC field
        itemUPCLabel = GUI_AMSStoreMain.makeLeftAlignedGrayLabel("Return Item UPC", 11);
        this.add(itemUPCLabel);
        itemUPCField = GUI_AMSStoreMain.makeLeftGrayTextField("", 200);
		this.add(itemUPCField);
		
		this.add(Box.createRigidArea(new Dimension(0,10)));
		
		// result label
		resultLabel = GUI_AMSStoreMain.makeLeftAlignedGrayLabel("", 11);
        this.add(resultLabel);

		this.add(Box.createRigidArea(new Dimension(0,15)));
		
		 // amount to return
        amountLabel = GUI_AMSStoreMain.makeLeftAlignedGrayLabel("Amount to return", 11);
        this.add(amountLabel);
		amountField = GUI_AMSStoreMain.makeLeftGrayTextField("1", 70);
		this.add(amountField);
		
		this.add(Box.createRigidArea(new Dimension(0,5)));

        // confirm return button
        returnItemButton = GUI_AMSStoreMain.makeGrayWhiteButton("Return this Item", Component.LEFT_ALIGNMENT);
        returnItemButton.setEnabled(false);
        this.add(returnItemButton);
	}
	
	public void resetPage()
	{	
		this.remove(storeList);
		// list of stores to choose from, by default on first one
        Object[] tableStrings = storeOptions.toArray();
        storeList = new JComboBox(tableStrings);
        storeList.setSelectedIndex(0);
        storeList.setAlignmentX(Component.LEFT_ALIGNMENT);
        storeList.setForeground(Color.gray);
        storeList.setBackground(Color.white);
        storeList.setFont(new Font("Century Gothic", Font.PLAIN, 13));
        storeList.setMaximumSize(new Dimension(200,25));
        storeList.setSize(new Dimension(200, 25));
        this.add(storeList,5);
        
        returnItemButton.setEnabled(false);
        amountField.setText("1");
        itemUPCField.setText("");
        receiptIDField.setText("");
	}
}
